package com.tang.websocket.v1.test;

import com.tang.websocket.v1.handler.AbstractWebSocketHandler;
import com.tang.websocket.v1.message.WebSocketMessage;
import com.tang.websocket.v1.session.SessionPath;
import com.tang.websocket.v1.session.SimpleSessionPath;
import com.tang.websocket.v1.session.WebSocketSession;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author Tang
 * @classname SimpleWebSocketHandler
 * @description [  业务handler ]
 * @date 2022/11/29 11:33
 */
@Component
public class SimpleWebSocketHandler extends AbstractWebSocketHandler {

    @Override
    public void onMessage(WebSocketSession webSocketSession, WebSocketMessage<?> message) throws IOException {
        System.out.println("msg:" + message.getPayLoad());
        // todo 处理消息
        webSocketSession.sendMessage(message);
    }

    @Override
    public SessionPath getSessionPath() {
        return new SimpleSessionPath("id");
    }

}
